<script setup>
import {inject, ref} from 'vue';
import useDesignerStore from '../../store/index';
const designerStore = useDesignerStore();
const menuList = ref([
  {name:'平移', icon:'fa fa-arrows', type: 'PAN'},
  {name:'禁用视野缩放平移', icon:'fa fa-arrows-alt', type: 'BAN'},
  {name:'绘制点', icon:'fa fa-dot-circle-o', type: 'POINT'},
  {name:'绘制圆', icon:'fa fa-circle-o', type: 'CIRCLE'},
  {name:'绘制线', icon:'fa fa-minus', type: 'LINE'},
  {name:'绘制多段线', icon:'fa fa-minus-square-o', type: 'POLYLINE'},
  {name:'绘制矩形', icon:'fa fa-square-o', type: 'RECT'},
  {name:'绘制多边形', icon:'fa fa-star-o', type: 'POLYGON'},
  {name:'绘制涂抹', icon:'fa fa-eraser', type: 'DRAWMASK'},
  {name:'擦除涂抹', icon:'fa fa-eraser', type: 'CLEARMASK'},
  {name:'绘制涂抹（Image形式）', icon:'fa fa-image', type: 'IMAGEMASK'},
]);

const gMap = inject('gMap')


function handleClick(type) {
  switch (type) {
    case 'OPEN_FOLDER':
      console.log('open folder');
      break;
    case 'SAVE':
      console.log('save');
      break;
      default:
        gMap.value.setMode(type);
        designerStore.mode=type;
        break;
  }
}
</script>
<template>
  <div class="left-menu">
    <div class="menu">
      <div class="menu-item" v-for="(item, index) in menuList" :key="index" @click="handleClick(item.type)">
        <el-tooltip :content="item.name" placement="right">
          <i :class="item.icon"></i>
        </el-tooltip>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.left-menu {
  height: 80%;
  width: 50px;
  background-color: #ffffff;
  position: fixed;
  top: 0;
  bottom: 0;
  margin: auto;
  left: 20px;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 10px;
  //justify-content: center;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  padding: 10px 0;


  .menu {
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    align-content: flex-start;
    align-items: center;
    overflow-y: scroll;
    overflow-x: hidden;
    transition: all 0.3s ease-in-out;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
    &::-webkit-scrollbar {
      width: 0;  /* Remove scrollbar space */
      background: transparent;  /* Optional: just make scrollbar invisible */
    }

    .menu-item {
      width: 40px;
      height: 40px;
      //margin-top: 5px;
      //margin-bottom: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      //border-radius: 50%;
      background-color: #fff;
      cursor: pointer;

      &:hover {
        background-color: #dcdcdc;
      }

      i {
        font-size: 20px;
        color: #0574d2;
      }
    }
  }
}
</style>